﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPFLib.Win
{
    /// <summary>
    /// WPFWindows.xaml 的交互逻辑
    /// </summary>
    public partial class WPFWindows : Window
    {
        string path = "./Resource/Image";
        /// <summary>
        /// 用于图标列表
        /// </summary>
        CComboBoxViewList cComboBoxViewList = new CComboBoxViewList();

        public WPFWindows()
        {
            InitializeComponent();
            LoadedImage();
        }

        private void LoadedImage()
        {
            DirectoryInfo folder = new DirectoryInfo(path);

            ImageSource imageSource = null;

            foreach (FileInfo file in folder.GetFiles("*.png"))
            {
                imageSource = new BitmapImage(new Uri(path + "/" + file.Name, UriKind.Relative));
                cComboBoxViewList.CComboBoxViews.Add(new CComboBoxView()
                {
                    IgSource = imageSource,
                    FileName = file.Name
                });
            }

            cmbOpenImage.DataContext = cComboBoxViewList;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
